import { FilterDTO } from "@/utils/api/interface/index";

import http from "@/utils/api";
import { Key } from "react";

export enum RolePermission{
	read='read' , edit='edit',fullControl= 'fullControl'
} 


export const roleView = (id: string) => {
	return http.get<Role.RoleDTO>(`/role/view/` + id);
};
export const roleSimpleList = () => {
	return http.get<IdName[]>(`/role/simpleList`);
};
export const roleDelete = (id: string) => {
	return http.delete<Role.RoleDTO>(`/role/` + id);
};

export const roleList = (params: FilterDTO) => {
	return http.post<Role.RoleDTO[]>(`/role/list`, params);
};
export const roleSave = (params: Role.RoleDTO) => {
	return http.post<Role.RoleDTO>(`/role/save`, params);
};

// 用户
export namespace Role {
	export interface RoleDTO {
		roleId: string;
		roleName: string;
		note: string;
		disable: boolean;
		createBy: string;
		createTime: string;
		updateBy: string;
		updateTime: string;
		isSys: boolean;
		resArr: RoleResDTO[];
	}
	export interface RoleResDTO {
		resId: string;
		title: string;
		read?: boolean;
		edit?: boolean;
		fullControl?: boolean;
		readIndeterminate?: boolean;
		editIndeterminate?: boolean;
		fullControlIndeterminate?: boolean;
		children?: Array<RoleResDTO>;
	}
}
